<?php
class SelectField extends CWidget {
	/*
		name:
		value:
		label:
			value:
			htmlOptions:
		options:
			option:
				value:
				label:
				selected: true/false
		htmlOptions:
	*/
	
	public $name;
	public $value;
	public $label = array(
		"value"=>"",
		"htmlOptions"=>"",
	);
	public $options = array();
	
	
	public $htmlOptions;
	
	public function init(){
		$val = Yii::app()->request->getParam($this->name,$this->value);		
		$this->value = $val;
		$this->label = array_merge(array("value"=>"","htmlOptions"=>""),$this->label);
		for($i=0;$i < count($this->options);$i++){
			if ($this->options[$i]["value"] == $val){
				$this->options[$i]["selected"] = true;
			}else{
				$this->options[$i]["selected"] = false;
			}
		}
	}
	
    public function run() {
		$this->render('selectField');
    }
}
?>